<#-- @ftlvariable name="entity" type="com.xci.edu.core.entity.EduCourseware" -->
<#include "/sys/_layout.ftl">
<#assign allowInsert=sysWeb.auth("background.eduCourseware.insert")/>
<#assign allowUpdate=sysWeb.auth("background.eduCourseware.update")/>
<#assign allowDelete=sysWeb.auth("background.eduCourseware.delete")/>
<#assign allowExport=sysWeb.auth("background.eduCourseware.export")/>
<!doctype html>
<html>
<head>
    <@pageHeader/>
</head>
<body>
<@pageLoading/>
<div id="gridtoolbar">
    <form id="gridform" class="jxlayout-form form-inline jxform">
        <div class="form-group">
            <input name="name" class="form-control w-250px" placeholder="请输入查询关键字" autocomplete="off">
        </div>
        <div class="form-group" >
            <#--            <select name="courseType" class="jxselect form-control" data-select-submit="true" data-allow-clear="false" data-width="110">-->
            <#--                ${web.statusSelectOptions()}-->
            <#--            </select>-->
            <select name="courseType" class="jxselect form-control" data-select-submit="true" data-width="140" data-allow-clear="false">
                <option value=" " selected>请选择课件类型</option>
                <option value="0">图片</option>
                <option value="1">视频</option>
            </select>
        </div>
        <div class="form-group" >
            <select class="form-control jxselect" name="eduCategoryId" data-select-submit="true" data-width="140" data-allow-clear="false">
                <option value=" " selected>请选择从业类别</option>
                <@eduCategorySelectOption selectedValue=entity.eduCategoryId></@eduCategorySelectOption>
            </select>
        </div>
        <button class="btn btn-primary ml-5" type="submit">
            <i class="fa fa-search"></i> 查询
        </button>
        <div class="btn-group">
            <@echo test=allowInsert>
                <a class="btn btn-default" onclick="curd.createData()">
                    <i class="icon-plus"></i> 新建
                </a>
            </@echo>
            <@echo test=allowUpdate>
                <a class="btn btn-default" onclick="curd.editData()">
                    <i class="icon-pencil"></i> 编辑
                </a>
            </@echo>
            <@echo test=allowDelete>
                <a class="btn btn-default" onclick="curd.deleteData()">
                    <i class="icon-trash"></i> 删除
                </a>
            </@echo>
            <@echo test=allowExport>
                <a class="btn btn-default" onclick="curd.exportData()">
                    <i class="icon-share-alt"></i> 导出
                </a>
            </@echo>
        </div>
    </form>
</div>
<table id="grid" data-options="form:'#gridform',toolbar:'#gridtoolbar'">
    <thead>
    <tr>
        <th data-options="field:'ck',checkbox:true"></th>
        <th data-options="title:'课程名称',field:'name',width:200,align:'left',sortable: false"></th>
        <th data-options="title:'本章节学时',field:'periodToText',width:200,align:'left',sortable: false"></th>
        <th data-options="title:'科目名称',field:'eduCategoryName',width:200,align:'left',sortable: false"></th>
        <th data-options="title:'课件类型',field:'courseTypeName',width:200,align:'left',sortable: false"></th>
        <th data-options="title:'排序号',field:'path',width:200,align:'left',sortable: false"></th>
        <th data-options="title:'操作人',field:'operateUserName',width:200,align:'left',sortable: false"></th>
        <th data-options="title:'操作时间',field:'operateDateTime',width:200,align:'left',sortable: false"></th>
        <th data-options="title:'操作',field:'id',align:'center',formatter: formatCommand"></th>
    </tr>
    </thead>
</table>

<script type="text/html" id="cmd_tpl">
    <div style="margin: 0 5px">
        <@echo test=allowUpdate><a class="cmd-edit" data-id="{0}">编辑</a></@echo>
        <@echo test=allowDelete><a class="cmd-delete" data-id="{0}">删除</a></@echo>
        <@echo test=allowUpdate><a class="cmd-category" data-id="{0}">课件</a></@echo>
    </div>
</script>

<@pageFooter/>
<script>

    function formatCommand(v) {
        return jx.formatString($('#cmd_tpl').html(), v);
    }

    jx.ready(function () {
        window.curd = new jx.GridCurd('#grid', {
            title: '课程信息',
            dialogWidth: '600px',
            dialogHeight: '400px',
            api: {
                grid: '/background/eduCourseware/grid',
                create: '/background/eduCourseware/create',
                edit: '/background/eduCourseware/edit',
                delete: '/background/eduCourseware/delete',
                details: '/background/eduCourseware/details',
                status: '/background/eduCourseware/status',
                export: '/background/eduCourseware/export'
            },

            onInit: function (instance) {
                //状态事件
                instance.gridPanel.on('click', '.gridstatus', function () {
                    instance.setStatusDataById($(this).data('id'), $(this).data('val') == '1' ? 0 : 1);
                });
                //编辑事件
                instance.gridPanel.on('click', '.cmd-edit', function () {
                    instance.editDataById($(this).data('id'));
                });
                //删除事件
                instance.gridPanel.on('click', '.cmd-delete', function () {
                    instance.deleteDataByIds([$(this).data('id')]);
                });
                //课件事件
                instance.gridPanel.on('click', '.cmd-category', function () {
                    instance.categoryById([$(this).data('id')]);
                });
            }
        });
        curd.categoryById = function (id) {
            jx.dialog({
                title: '课件添加',
                url: jx.url('/background/eduCoursewareDetails/create'),
                params: {roleIds: [id]},
                width: '80%',
                height: '80%'
            });
        };
    });
</script>
</body>
</html>
